<template>
  <div class="checkout">
    <h2>结算</h2>
    <p>购物车总金额: {{ totalPrice }}</p>
    <button @click="placeOrder">确认下单</button>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  name: 'Checkout',
  computed: {
    ...mapGetters(['totalPrice'])
  },
  methods: {
    placeOrder() {
      alert('订单已提交，总金额为：' + this.totalPrice);
      // 这里可以添加清空购物车等逻辑
      this.$store.commit('clearCart');
      this.$router.push('/home');
    }
  }
};
</script>

<style scoped>
/* 整体结算页面容器样式优化 */
.checkout {
  text-align: center;
  padding: 50px;
  background-color: #f8f9fa;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: 60%;
  margin: 20px auto;
}

/* 标题样式增强 */
.checkout h2 {
  color: #343a40;
  font-size: 32px;
  font-family: 'Arial', sans-serif;
  margin-bottom: 30px;
}

/* 购物车总金额样式突出显示 */
.checkout p {
  color: #e74c3c;
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 30px;
}

/* 确认下单按钮样式优化 */
.checkout button {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  font-size: 20px;
}

.checkout button:hover {
  background-color: #0056b3;
}

/* 鼠标悬停时整体容器添加阴影加深效果，增强交互感 */
.checkout:hover {
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}
</style>